﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using IssueIT.Core.Domain;
using IssueIT.Core.Domain.Model;

namespace IssueIT.Core.Services
{
    public class ProjectService : IProjectService
    {
        //TODO:Refactor so that validating the Uri can be called as ProjectService.ProjectUri.IsAllowed
        public bool IsAllowedProjectUri(string projectUri)
        {
            return new ProjectUriValidator(projectUri).IsAllowed;
        }

        public void CreateProject(Project newProject)
        {
               
        }

        public bool IsUnique(string projectUri)
        {
            bool result = true;
            //check at projekt uri ikke allerede tilhøre et andet projekt

            //test at projekt uri ikke er beskyttet system kommando
            result = CheckForProtectedUri(projectUri);

            return result;
        }

        private bool CheckForProtectedUri(string projectUri)
        {
            if (projectUri.Equals("admin", StringComparison.OrdinalIgnoreCase))
            {
                return false;
            }
            return true;
        }
    }
}
